package Scene4;

import Picture.GameImage;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Random;

public class wolf {
    BufferedImage img;
    ArrayList<BufferedImage> arrayListRight = new ArrayList<>();
    ArrayList<BufferedImage> arrayListLeft = new ArrayList<>();
    int indexL = 0;
    int indexR = 0;
    public  int speed = 1;
    public wolf() {
        img = GameImage.get("/Picture/wolf/wr1.png");
        for (int i = 1; i < 4; i++) {
            arrayListLeft.add(GameImage.get("/Picture/wolf/wl"+i+".png"));
        }
        for (int i = 1; i < 4; i++) {
            arrayListRight.add(GameImage.get("/Picture/wolf/wr"+i+".png"));
        }
    }

    public int x = 0;
    public int y = 700;
    int dir = 2;//1代表左边,2代表右边
    public void move(){
        if(dir ==1){
            x-=40+speed;
            if(speed<=80)
            speed++;
        }
        if(x>1400){
            dir = 1;
        }
        if(x<100){
            dir = 2;
        }
        if(dir == 2){

            x+=40+speed;
            if(speed<=80)
            speed++;
        }
    }
    public void changeImage(){
        if(indexL==3){
            indexL = 0;
        }
        if(indexR==3){
            indexR = 0;
        }
        if(dir == 1){
            img = arrayListLeft.get(indexL);
            indexL++;
        }
        if(dir == 2){
            img = arrayListRight.get(indexR);
            indexR++;
        }

    }



}
